package com.example.travel.util;

import android.Manifest;
import android.content.pm.PackageManager;
import android.os.Build;

import androidx.fragment.app.FragmentActivity;


/**
 * Created by DELL on 2020/11/2.
 */

public class  UtilPermission {
    public static void checkSend_SMS_Permission(FragmentActivity fa){
        if(Build.VERSION.SDK_INT>=23){
            int REQUEST_CODE_CONTACT=101;
            String [] permission={ Manifest.permission.SEND_SMS};
            for(String str:permission){
                if(fa.checkSelfPermission(str)!= PackageManager.PERMISSION_GRANTED){
                    fa.requestPermissions(permission,REQUEST_CODE_CONTACT);
                }
            }
        }
    }
    public static void checkCall_Phone_Permission(FragmentActivity fa){
        if(Build.VERSION.SDK_INT>=23){
            int REQUEST_CODE_CONTACT=101;
            String [] permission={ Manifest.permission.CALL_PHONE};
            for(String str:permission){
                if(fa.checkSelfPermission(str)!= PackageManager.PERMISSION_GRANTED){
                    fa.requestPermissions(permission,REQUEST_CODE_CONTACT);
                }
            }
        }
    }

    public static void checkWRITE_EXTERNAL_STORAGEpermission(FragmentActivity fa){
        if(Build.VERSION.SDK_INT>=23){
            int REQUEST_CODE_CONTACT=101;
            String [] permission={"android.permission.WRITE_EXTERNAL_STORAGE"};
            for(String str:permission){
                if(fa.checkSelfPermission(str)!= PackageManager.PERMISSION_GRANTED){
                    fa.requestPermissions(permission,REQUEST_CODE_CONTACT);
                }
            }
        }
    }
}
